package com.yueshop.order.vo;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

//封装订单确认页的数据
public class OrderConfirmVo {
    @Getter @Setter
    //会员收货地址列表
    List<MemberAddressVo> address;
    @Getter @Setter
    //所有选中的购物项
    List<OrderItemVo> items;
    @Getter @Setter
    private Map<Long,Boolean> stocks;

    //发票
    //优惠卷
    /**
     * 积分
     */
    @Getter @Setter
    private Integer integration;
    //商品总额
    private BigDecimal total;

    public BigDecimal getTotal() {
        BigDecimal total = new BigDecimal("0");
        if(items!=null){
            for (OrderItemVo item : items) {
                BigDecimal multiply = item.getPrice().multiply(new BigDecimal(item.getCount().toString()));
                total = total.add(multiply);
            }
        }
        return total;
    }
    @Getter@Setter
    //防重令牌
    private  String orderToken;

    //应付价格
    private BigDecimal payPrice;

    public BigDecimal getPayPrice() {
        return getTotal();
    }

    //商品件数
    private Integer count;

    public Integer getCount() {
        int count=0;
        if(items!=null){
            for (OrderItemVo item : items) {
                count+=item.getCount();
            }
        }
        return count;
    }


}
